package com.catchu.service.impl;

import com.catchu.dao.UserRepository;
import com.catchu.domain.User;
import com.catchu.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * @author 刘俊重
 * @Description
 * @date 11:53
 */
@Service
public class UserServiceImpl implements UserService{

    @Autowired
    private UserRepository userRepository;

    @Override
    public int save(User user) {
        User user2 = userRepository.save(user);
        return 0;
    }

    @Override
    public int delete(Long id) {
        userRepository.delete(id);
        return 0;
    }

    @Override
    public User findOne(Long id) {
        return userRepository.findOne(id);
    }

    @Override
    public List<User> findList(User user) {
        return userRepository.findAll();
    }

    @Override
    public int update(User user) {
        userRepository.save(user);
        return 0;
    }

    @Transactional
    @Override
    public int updateById(String name, Long id) {
        return userRepository.modifyByid(name,id);
    }
}
